﻿using System;
using System.Globalization;

namespace Dyao.Book.Contract.Serialization
{
    /// <summary>
    ///<see cref="DateTime"/>与json转换格式标记，默认格式："yyyy-MM-dd HH:mm:ss"
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public class DatetimeFormatAttribute : SerializeFormatterAttribute
    {
        /// <summary>
        /// 将日期与JSON转换时使用的日期时间格式,默认值："yyyy-MM-dd HH:mm:ss"
        /// </summary>
        public string Format { get; set; } = "yyyy-MM-dd HH:mm:ss";

        /// <summary>
        /// culture
        /// </summary>
        public CultureInfo Culture { get; set; }

        public DatetimeFormatAttribute() { }

        public DatetimeFormatAttribute(string format)
        {
            Format = format;
        }
    }
}
